<?php
namespace Swiftx\Scaffold;
use Swiftx\Interfaces\Scaffold\Config as IConfig;

/**
 * 框架配置程序
 *
 * @author		胡永强  <odaytudio@gmail.com>
 * @since		2015-11-11
 * @copyright	Copyright (c) 2014-2015 Swiftx Inc.
 */
class Config implements IConfig{

    /** @var array */
    protected $data = [];

    /**
     * 设置配置
     * @param string $key
     * @param $data
     */
    public function set(string $key, $data) {
        $this->data[$key] = $data;
    }

    /**
     * 写入配置
     * @param string $key
     * @return mixed
     */
    public function get(string $key) {
        if(!$this->exists($key)) return null;
        return $this->data[$key];
    }

    /**
     * 配置项是否存在
     * @param string $key
     * @return bool
     */
    public function exists(string $key):bool {
        return array_key_exists($key, $this->data);
    }

}